package org.example.demo.raw;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.fisco.bcos.sdk.abi.FunctionReturnDecoder;
import org.fisco.bcos.sdk.abi.TypeReference;
import org.fisco.bcos.sdk.abi.datatypes.Address;
import org.fisco.bcos.sdk.abi.datatypes.DynamicArray;
import org.fisco.bcos.sdk.abi.datatypes.Event;
import org.fisco.bcos.sdk.abi.datatypes.Function;
import org.fisco.bcos.sdk.abi.datatypes.Type;
import org.fisco.bcos.sdk.abi.datatypes.Utf8String;
import org.fisco.bcos.sdk.abi.datatypes.generated.Uint256;
import org.fisco.bcos.sdk.abi.datatypes.generated.Uint64;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple1;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple2;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple3;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple6;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.contract.Contract;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.eventsub.EventCallback;
import org.fisco.bcos.sdk.model.CryptoType;
import org.fisco.bcos.sdk.model.TransactionReceipt;
import org.fisco.bcos.sdk.model.callback.TransactionCallback;
import org.fisco.bcos.sdk.transaction.model.exception.ContractException;

@SuppressWarnings("unchecked")
public class Goods extends Contract {
    public static final String[] BINARY_ARRAY = {"608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506115d5806100606000396000f300608060405260043610610083576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632860b00d146100885780633ee61334146100bf578063663985db146101825780637c9753e4146102315780638da5cb5b14610288578063c81ee1cc146102df578063fc27a24f14610498575b600080fd5b34801561009457600080fd5b506100bd600480360381019080803567ffffffffffffffff1690602001909291905050506104af565b005b3480156100cb57600080fd5b50610180600480360381019080803567ffffffffffffffff169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610669565b005b34801561018e57600080fd5b5061022f600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610924565b005b34801561023d57600080fd5b50610286600480360381019080803567ffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c5f565b005b34801561029457600080fd5b5061029d610f20565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102eb57600080fd5b50610314600480360381019080803567ffffffffffffffff169060200190929190505050610f45565b604051808767ffffffffffffffff1667ffffffffffffffff16815260200180602001806020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001858152602001848103845289818151815260200191508051906020019080838360005b838110156103ae578082015181840152602081019050610393565b50505050905090810190601f1680156103db5780820380516001836020036101000a031916815260200191505b50848103835288818151815260200191508051906020019080838360005b838110156104145780820151818401526020810190506103f9565b50505050905090810190601f1680156104415780820380516001836020036101000a031916815260200191505b50848103825286818151815260200191508051906020019060200280838360005b8381101561047d578082015181840152602081019050610462565b50505050905001995050505050505050505060405180910390f35b3480156104a457600080fd5b506104ad61119f565b005b3373ffffffffffffffffffffffffffffffffffffffff16600160008367ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156105c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c7920746865206f776e65722063616e2072656d6f76652074686520676f81526020017f6f6473000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600160008267ffffffffffffffff1667ffffffffffffffff168152602001908152602001600020600080820160006101000a81549067ffffffffffffffff0219169055600182016000610615919061134e565b600282016000610625919061134e565b6003820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560048201600061065c9190611396565b6005820160009055505050565b3373ffffffffffffffffffffffffffffffffffffffff16600160008567ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561077c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c7920746865206f776e65722063616e207570646174652074686520676f81526020017f6f6473000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b81600160008567ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060010190805190602001906107ba9291906113b7565b5080600160008567ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060020190805190602001906107f99291906113b7565b507f6807d748eb71b761f22443e1cd69eb40d32ba81de60c688109182742dbdee2f3838383604051808467ffffffffffffffff1667ffffffffffffffff1681526020018060200180602001838103835285818151815260200191508051906020019080838360005b8381101561087c578082015181840152602081019050610861565b50505050905090810190601f1680156108a95780820380516001836020036101000a031916815260200191505b50838103825284818151815260200191508051906020019080838360005b838110156108e25780820151818401526020810190506108c7565b50505050905090810190601f16801561090f5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1505050565b60006002600081819054906101000a900467ffffffffffffffff168092919060010191906101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550905060c0604051908101604052808267ffffffffffffffff1681526020018481526020018381526020013373ffffffffffffffffffffffffffffffffffffffff16815260200160016040519080825280602002602001820160405280156109e25781602001602082028038833980820191505090505b50815260200142815250600160008367ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506020820151816001019080519060200190610a5e929190611437565b506040820151816002019080519060200190610a7b929190611437565b5060608201518160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506080820151816004019080519060200190610adf9291906114b7565b5060a0820151816005015590505033600160008367ffffffffffffffff1667ffffffffffffffff1681526020019081526020016000206004016000815481101515610b2657fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f6a214fc79dacdf9f178e39ed05b4fa2e826277691119d2a34b37cb1f934fd2be818433604051808467ffffffffffffffff1667ffffffffffffffff168152602001806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b83811015610c1e578082015181840152602081019050610c03565b50505050905090810190601f168015610c4b5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1505050565b3373ffffffffffffffffffffffffffffffffffffffff16600160008467ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610d72576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001807f4f6e6c7920746865206f776e65722063616e207472616e73666572207468652081526020017f676f6f647300000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b80600160008467ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600160008367ffffffffffffffff1667ffffffffffffffff1681526020019081526020016000206004018190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550507f7dce5cf2ff77fdf6398b4854e444f174727b0b0b5636ecbd04344d7eba355808823383604051808467ffffffffffffffff1667ffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001935050505060405180910390a15050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060608060006060600080600160008967ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002090508060000160009054906101000a900467ffffffffffffffff16816001018260020183600301","60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846004018560050154848054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561105e5780601f106110335761010080835404028352916020019161105e565b820191906000526020600020905b81548152906001019060200180831161104157829003601f168201915b50505050509450838054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110fa5780601f106110cf576101008083540402835291602001916110fa565b820191906000526020600020905b8154815290600101906020018083116110dd57829003601f168201915b505050505093508180548060200260200160405190810160405280929190818152602001828054801561118257602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311611138575b505050505091509650965096509650965096505091939550919395565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561128b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001807f4f6e6c7920746865206f776e65722063616e2063616c6c20746869732066756e81526020017f6374696f6e00000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600260009054906101000a900467ffffffffffffffff1690506000600260006101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055507f28789814d268fc25430d96e4a584d003a21591da8f498ce4d0e5abd9b7c8362581600260009054906101000a900467ffffffffffffffff16604051808367ffffffffffffffff1667ffffffffffffffff1681526020018267ffffffffffffffff1667ffffffffffffffff1681526020019250505060405180910390a150565b50805460018160011615610100020316600290046000825580601f106113745750611393565b601f0160209004906000526020600020908101906113929190611541565b5b50565b50805460008255906000526020600020908101906113b49190611541565b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106113f857805160ff1916838001178555611426565b82800160010185558215611426579182015b8281111561142557825182559160200191906001019061140a565b5b5090506114339190611541565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061147857805160ff19168380011785556114a6565b828001600101855582156114a6579182015b828111156114a557825182559160200191906001019061148a565b5b5090506114b39190611541565b5090565b828054828255906000526020600020908101928215611530579160200282015b8281111561152f5782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550916020019190600101906114d7565b5b50905061153d9190611566565b5090565b61156391905b8082111561155f576000816000905550600101611547565b5090565b90565b6115a691905b808211156115a257600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690555060010161156c565b5090565b905600a165627a7a7230582061f9502cc8c6c97c03c0fbff6108a9f608defcc08fe9eb915ca2f0fe6d356fe10029"};

    public static final String BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", BINARY_ARRAY);

    public static final String[] SM_BINARY_ARRAY = {};

    public static final String SM_BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", SM_BINARY_ARRAY);

    public static final String[] ABI_ARRAY = {"[{\"constant\":false,\"inputs\":[{\"name\":\"goodsId\",\"type\":\"uint64\"}],\"name\":\"removeGoods\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"goodsId\",\"type\":\"uint64\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"}],\"name\":\"updateGoods\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"}],\"name\":\"addGoods\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"goodsId\",\"type\":\"uint64\"},{\"name\":\"to\",\"type\":\"address\"}],\"name\":\"transferGoods\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"goodsId\",\"type\":\"uint64\"}],\"name\":\"getGoods\",\"outputs\":[{\"name\":\"\",\"type\":\"uint64\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"string\"},{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"address[]\"},{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"resetGoodsId\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"goodsId\",\"type\":\"uint64\"},{\"indexed\":false,\"name\":\"name\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"GoodsCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"goodsId\",\"type\":\"uint64\"},{\"indexed\":false,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"to\",\"type\":\"address\"}],\"name\":\"GoodsTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"goodsId\",\"type\":\"uint64\"},{\"indexed\":false,\"name\":\"name\",\"type\":\"string\"},{\"indexed\":false,\"name\":\"description\",\"type\":\"string\"}],\"name\":\"GoodsUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"oldId\",\"type\":\"uint64\"},{\"indexed\":false,\"name\":\"newId\",\"type\":\"uint64\"}],\"name\":\"GoodsIdReset\",\"type\":\"event\"}]"};

    public static final String ABI = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", ABI_ARRAY);

    public static final String FUNC_REMOVEGOODS = "removeGoods";

    public static final String FUNC_UPDATEGOODS = "updateGoods";

    public static final String FUNC_ADDGOODS = "addGoods";

    public static final String FUNC_TRANSFERGOODS = "transferGoods";

    public static final String FUNC_OWNER = "owner";

    public static final String FUNC_GETGOODS = "getGoods";

    public static final String FUNC_RESETGOODSID = "resetGoodsId";

    public static final Event GOODSCREATED_EVENT = new Event("GoodsCreated", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Address>() {}));
    ;

    public static final Event GOODSTRANSFERRED_EVENT = new Event("GoodsTransferred", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}, new TypeReference<Address>() {}, new TypeReference<Address>() {}));
    ;

    public static final Event GOODSUPDATED_EVENT = new Event("GoodsUpdated", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
    ;

    public static final Event GOODSIDRESET_EVENT = new Event("GoodsIdReset", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}, new TypeReference<Uint64>() {}));
    ;

    protected Goods(String contractAddress, Client client, CryptoKeyPair credential) {
        super(getBinary(client.getCryptoSuite()), contractAddress, client, credential);
    }

    public static String getBinary(CryptoSuite cryptoSuite) {
        return (cryptoSuite.getCryptoTypeConfig() == CryptoType.ECDSA_TYPE ? BINARY : SM_BINARY);
    }

    public TransactionReceipt removeGoods(BigInteger goodsId) {
        final Function function = new Function(
                FUNC_REMOVEGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId)), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void removeGoods(BigInteger goodsId, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_REMOVEGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId)), 
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForRemoveGoods(BigInteger goodsId) {
        final Function function = new Function(
                FUNC_REMOVEGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId)), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple1<BigInteger> getRemoveGoodsInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_REMOVEGOODS, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple1<BigInteger>(

                (BigInteger) results.get(0).getValue()
                );
    }

    public TransactionReceipt updateGoods(BigInteger goodsId, String name, String description) {
        final Function function = new Function(
                FUNC_UPDATEGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(description)), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void updateGoods(BigInteger goodsId, String name, String description, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_UPDATEGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(description)), 
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForUpdateGoods(BigInteger goodsId, String name, String description) {
        final Function function = new Function(
                FUNC_UPDATEGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(description)), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple3<BigInteger, String, String> getUpdateGoodsInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_UPDATEGOODS, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple3<BigInteger, String, String>(

                (BigInteger) results.get(0).getValue(), 
                (String) results.get(1).getValue(), 
                (String) results.get(2).getValue()
                );
    }

    public TransactionReceipt addGoods(String name, String description) {
        final Function function = new Function(
                FUNC_ADDGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(description)), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void addGoods(String name, String description, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_ADDGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(description)), 
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForAddGoods(String name, String description) {
        final Function function = new Function(
                FUNC_ADDGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.Utf8String(name), 
                new org.fisco.bcos.sdk.abi.datatypes.Utf8String(description)), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple2<String, String> getAddGoodsInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_ADDGOODS, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple2<String, String>(

                (String) results.get(0).getValue(), 
                (String) results.get(1).getValue()
                );
    }

    public TransactionReceipt transferGoods(BigInteger goodsId, String to) {
        final Function function = new Function(
                FUNC_TRANSFERGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId), 
                new org.fisco.bcos.sdk.abi.datatypes.Address(to)), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void transferGoods(BigInteger goodsId, String to, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_TRANSFERGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId), 
                new org.fisco.bcos.sdk.abi.datatypes.Address(to)), 
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForTransferGoods(BigInteger goodsId, String to) {
        final Function function = new Function(
                FUNC_TRANSFERGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId), 
                new org.fisco.bcos.sdk.abi.datatypes.Address(to)), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple2<BigInteger, String> getTransferGoodsInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_TRANSFERGOODS, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}, new TypeReference<Address>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple2<BigInteger, String>(

                (BigInteger) results.get(0).getValue(), 
                (String) results.get(1).getValue()
                );
    }

    public String owner() throws ContractException {
        final Function function = new Function(FUNC_OWNER, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}));
        return executeCallWithSingleValueReturn(function, String.class);
    }

    public Tuple6<BigInteger, String, String, String, List<String>, BigInteger> getGoods(BigInteger goodsId) throws ContractException {
        final Function function = new Function(FUNC_GETGOODS, 
                Arrays.<Type>asList(new org.fisco.bcos.sdk.abi.datatypes.generated.Uint64(goodsId)), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint64>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Address>() {}, new TypeReference<DynamicArray<Address>>() {}, new TypeReference<Uint256>() {}));
        List<Type> results = executeCallWithMultipleValueReturn(function);
        return new Tuple6<BigInteger, String, String, String, List<String>, BigInteger>(
                (BigInteger) results.get(0).getValue(), 
                (String) results.get(1).getValue(), 
                (String) results.get(2).getValue(), 
                (String) results.get(3).getValue(), 
                convertToNative((List<Address>) results.get(4).getValue()), 
                (BigInteger) results.get(5).getValue());
    }

    public TransactionReceipt resetGoodsId() {
        final Function function = new Function(
                FUNC_RESETGOODSID, 
                Arrays.<Type>asList(), 
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void resetGoodsId(TransactionCallback callback) {
        final Function function = new Function(
                FUNC_RESETGOODSID, 
                Arrays.<Type>asList(), 
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForResetGoodsId() {
        final Function function = new Function(
                FUNC_RESETGOODSID, 
                Arrays.<Type>asList(), 
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public List<GoodsCreatedEventResponse> getGoodsCreatedEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(GOODSCREATED_EVENT, transactionReceipt);
        ArrayList<GoodsCreatedEventResponse> responses = new ArrayList<GoodsCreatedEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            GoodsCreatedEventResponse typedResponse = new GoodsCreatedEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.goodsId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.name = (String) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.owner = (String) eventValues.getNonIndexedValues().get(2).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeGoodsCreatedEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(GOODSCREATED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,fromBlock,toBlock,otherTopics,callback);
    }

    public void subscribeGoodsCreatedEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(GOODSCREATED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,callback);
    }

    public List<GoodsTransferredEventResponse> getGoodsTransferredEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(GOODSTRANSFERRED_EVENT, transactionReceipt);
        ArrayList<GoodsTransferredEventResponse> responses = new ArrayList<GoodsTransferredEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            GoodsTransferredEventResponse typedResponse = new GoodsTransferredEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.goodsId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.from = (String) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.to = (String) eventValues.getNonIndexedValues().get(2).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeGoodsTransferredEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(GOODSTRANSFERRED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,fromBlock,toBlock,otherTopics,callback);
    }

    public void subscribeGoodsTransferredEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(GOODSTRANSFERRED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,callback);
    }

    public List<GoodsUpdatedEventResponse> getGoodsUpdatedEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(GOODSUPDATED_EVENT, transactionReceipt);
        ArrayList<GoodsUpdatedEventResponse> responses = new ArrayList<GoodsUpdatedEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            GoodsUpdatedEventResponse typedResponse = new GoodsUpdatedEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.goodsId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.name = (String) eventValues.getNonIndexedValues().get(1).getValue();
            typedResponse.description = (String) eventValues.getNonIndexedValues().get(2).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeGoodsUpdatedEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(GOODSUPDATED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,fromBlock,toBlock,otherTopics,callback);
    }

    public void subscribeGoodsUpdatedEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(GOODSUPDATED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,callback);
    }

    public List<GoodsIdResetEventResponse> getGoodsIdResetEvents(TransactionReceipt transactionReceipt) {
        List<Contract.EventValuesWithLog> valueList = extractEventParametersWithLog(GOODSIDRESET_EVENT, transactionReceipt);
        ArrayList<GoodsIdResetEventResponse> responses = new ArrayList<GoodsIdResetEventResponse>(valueList.size());
        for (Contract.EventValuesWithLog eventValues : valueList) {
            GoodsIdResetEventResponse typedResponse = new GoodsIdResetEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.oldId = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.newId = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeGoodsIdResetEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(GOODSIDRESET_EVENT);
        subscribeEvent(ABI,BINARY,topic0,fromBlock,toBlock,otherTopics,callback);
    }

    public void subscribeGoodsIdResetEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(GOODSIDRESET_EVENT);
        subscribeEvent(ABI,BINARY,topic0,callback);
    }

    public static Goods load(String contractAddress, Client client, CryptoKeyPair credential) {
        return new Goods(contractAddress, client, credential);
    }

    public static Goods deploy(Client client, CryptoKeyPair credential) throws ContractException {
        return deploy(Goods.class, client, credential, getBinary(client.getCryptoSuite()), "");
    }

    public static class GoodsCreatedEventResponse {
        public TransactionReceipt.Logs log;

        public BigInteger goodsId;

        public String name;

        public String owner;
    }

    public static class GoodsTransferredEventResponse {
        public TransactionReceipt.Logs log;

        public BigInteger goodsId;

        public String from;

        public String to;
    }

    public static class GoodsUpdatedEventResponse {
        public TransactionReceipt.Logs log;

        public BigInteger goodsId;

        public String name;

        public String description;
    }

    public static class GoodsIdResetEventResponse {
        public TransactionReceipt.Logs log;

        public BigInteger oldId;

        public BigInteger newId;
    }
}
